<template>
	<div class="">
		<header class="top_bar">
			<a onclick="window.history.go(-1)" class="icon_back"></a>
			<h3 class="cartname">推荐二维码</h3>
		</header>
		<div class="erweima_bg">
			<div class="text_align_ct" style="padding-top: 130px;">
				<img v-lazy="erweima_src" style="width: 180px;height: 180px;" />
			</div>
			<div class="huiyuan_wrap" style="text-align: center;">
				<p>会员账号：{{uInfs.UserName}}</p>
				<!--<p>会员等级：{{uInfs.GradeId}}</p>-->
				<p>婴盾母婴商城</p>
			</div>
		</div>
	</div>
</template>
<script>
	import { Toast } from 'mint-ui';
	import QRCode from 'qrcode'

	export default {
		data() {
			return {
				root: this.root,
				erweima_src: '',
				uInfs: {},
			}
		},
		mounted() {
			let _this = this
			_this.GetErWeiMaData()
			_this.getUDatas()
		},
		methods: {
			GetErWeiMaData() {
				let _this = this;
				_this.$http.get('/wechat/qrcode', null, localStorage.Authorization, res => {
					console.log('获取推荐二维码res', res)
					if(res.code === 200) {
//						_this.erweima_src = res.data
						QRCode.toDataURL('http://wx.yingdun.com.cn/wx/register?referUserId='+res.data, function(err, url) {
							_this.erweima_src = url
						})
					}
				})
			},
			getUDatas() {
				let _this = this;
				_this.$http.get('/client/Members', null, localStorage.Authorization, res => {
					console.log('我的账户res', res)
					if(res.code === 200) {
						if(res.data.dataCount > 0) {
							_this.uInfs = res.data.list[0];
						} else {
							_this.uInfs.Balance = 0;
							_this.uInfs.Points = 0;

						}
					} else if(res.code === 101) {
						localStorage.fromPath = _this.$route.fullPath
						_this.$router.push({
							path: '/wx/login'
						})
					}
				})
			},
		}
	}
</script>
<style>
	@import '../assets/css/login.css';
</style>
<style scoped="scoped">
	.erweima_bg {
		width: 100%;
		height: 100%;
		background: url(../assets/images/erweima_bg.jpg) no-repeat center center;
		background-size: 100% 100%;
		position: absolute;
	}
	
	.huiyuan_wrap {
		width: 240px;
		margin: 0 auto;
		border: 1px dashed #FFFFFF;
		border-radius: 10px;
		background: #f88041;
		margin-top: 40px;
		padding: 10px;
	}
	
	.huiyuan_wrap p {
		font-size: 16px;
		color: #fff;
		line-height: 2em;
	}
</style>